{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="用户昵称|内容"/>
                        </div>
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="h_type" id="h_type" class="layui-input">
                                <option value="" >全部分类</option>
                                {foreach name="types" item="v"}
                                <option value="{$v.type_id}">{$v.type_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="h_cate" class="layui-input">
                                <option value="" >不限类型</option>
                                <option value="1">图文类型</option>
                                <option value="2">视频类型</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('add')}');">-->
                        <!--<i class="fa fa-plus"></i> 添加-->
                        <!--</button>-->
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('unbookAdd')}');" style="margin-left: 5px">-->
                        <!--<i class="fa fa-plus"></i> 添加非图书-->
                        <!--</button>-->

                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--&lt;!&ndash;<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>&ndash;&gt;-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-check-circle"></i> 批量上架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-ban"></i> 批量下架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <!--<div class="col-sm-12">-->
                    <!--<div class="input-group" >-->
                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                            <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    <!--</div>-->
                <!--</div>-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                        {{# if(d.h_cate == 1){ }}
                        <ul class="aaasss">
                            {{#  layui.each(d.h_image, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                        {{# } }}
                        {{# if(d.h_cate == 2){ }}
                        <video src="{{d.h_image}}" controls="controls"></video>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="h_cate">
                    {{# if(d.h_cate == 1){ }}
                    图文类型
                    {{# } }}
                    {{# if(d.h_cate == 2){ }}
                    视频类型
                    {{# } }}
                    </script>
                    <script type="text/html" id="h_top">
                    {{# if(d.h_top == 1){ }}
                    未推荐
                    {{# } }}
                    {{# if(d.h_top == 2){ }}
                    <span style="color: red;">推荐</span>
                    {{# } }}
                    </script>
                    <script type="text/html" id="h_status">
                    {{# if(d.h_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.h_status == 2){ }}
                    <span style="color: red;">下架</span>
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        {{# if(d.h_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.h_id}}','{:url('xiajia')}','下架?')" class="btn btn-primary btn-xs m-r-xs" title="下架">下架</a>
                        {{# } }}
                        {{# if(d.h_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.h_id}}','{:url('shangjia')}','上架?')" class="btn btn-danger btn-xs m-r-xs" title="上架">上架</a>
                        {{# } }}

                        {{# if(d.h_top == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.h_id}}','{:url('topyes')}','推荐?')" class="btn btn-primary btn-xs m-r-xs" title="推荐">推荐</a>
                        {{# } }}
                        {{# if(d.h_top == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.h_id}}','{:url('topno')}','取消推荐?')" class="btn btn-danger btn-xs m-r-xs" title="取消推荐">取消推荐</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('评论列表', '{:url('dynComment')}?h_id={{d.h_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看评论">查看评论</a>
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('dynDetail')}?h_id={{d.h_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.h_id}}','{:url('dynDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("dyn/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'h_content', width: '', title: '发布内容', align: 'center'}
                , {field: 'h_cate', width: 150, title: '类型', align: 'center',templet: '#h_cate'}
                , {field: 'h_image', width: 150, title: '配图/视频', align: 'center',templet: '#imgTpl'}
                , {field: 'user_username', width: '', title: '发布用户', align: 'center'}
                , {field: 'h_yinyan', width: '', title: '引言', align: 'center'}
                , {field: 'h_address', width: '', title: '地址', align: 'center'}
                , {field: 'h_message', width: 130, title: '评论数', align: 'center'}
                , {field: 'h_zhuan', width: 130, title: '转发数', align: 'center'}
                , {field: 'h_yes', width: 130, title: '点赞数', align: 'center'}
                , {field: 'h_no', width: 130, title: '踩数', align: 'center'}
                , {field: 'h_top', width: 130, title: '是否推荐', align: 'center',templet: '#h_top'}
                , {field: 'h_status', width: 130, title: '状态', align: 'center',templet: '#h_status'}
                , {field: 'h_time', width: '', title: '发布时间', align: 'center'}
                , {field: 'h_update_time', width: 130, title: '最后操作时间', align: 'center'}
                , {fixed: 'right', width:300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>